<?php use_helper('jQuery'); ?>
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<div id="consulta_exito" class="exito" style="display:<?php echo $display; ?>">Tu consulta ha sido enviada correctamente. Será publicada en unos instantes.</div>
<?php echo jq_form_remote_tag(array( 
          'url'      => url_for('consulta/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')),
          'script'   => true,
          'loading'  => "$('#indicator').fadeIn(500);",
          'update'   => "respuesta",
          ), 
          array('id' => 'form_consulta')
        );
        
        ?>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
 <?php echo $form; ?>
<div id="submit_consulta">
  <input type="submit" value="Realizar pregunta ahora" />
  <div id="indicator" style="float:left; margin:3px 0px 0px 10px; display:none;"><?php echo image_tag('ajax-loader.gif')?></div>
</div>
</form>
<?php 
  if ($display=='block')
    echo javascript_tag(
      "setTimeout( function(){ $('#consulta_exito').fadeOut(2000) }, 3000);"
    );
?>